<template>
  <div class="download-page">
    <div class="download-card">
      <img src="/logo.png" alt="logo" class="logo" />
      <div class="download-title">华拓工时管理APP下载</div>
      <div class="download-desc">请使用手机扫码下载或在手机端直接点击下方按钮</div>
      <div class="qr-section" v-if="showQr">
        <img src="/qr-code.png" alt="二维码" class="qr-code" />
        <div class="qr-tip">扫码下载APP</div>
      </div>
      <a
        class="download-btn"
        :href="apkUrl"
        v-if="showBtn"
        download
      >
        立即下载APP
      </a>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
const apkUrl = 'http://49.7.230.17:5173/download/htWorkLogManage.apk'
const showBtn = ref(false)
const showQr = ref(false)

function updateLayout() {
  const ratio = window.innerHeight / window.innerWidth
  if (ratio > 1) {
    // 竖屏，优先按钮
    showBtn.value = true
    showQr.value = false
  } else {
    // 横屏，优先二维码
    showBtn.value = false
    showQr.value = true
  }
}

onMounted(() => {
  updateLayout()
  window.addEventListener('resize', updateLayout)
})
</script>

<style scoped>
.download-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e0e7ff 0%, #f0fdfa 100%);
}
.download-card {
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.12);
  padding: 40px 32px 32px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 320px;
  max-width: 90vw;
}
.logo {
  width: 80px;
  height: 80px;
  object-fit: contain;
  margin-bottom: 18px;
}
.download-title {
  font-size: 1.6rem;
  font-weight: bold;
  color: #2d3a4b;
  margin-bottom: 8px;
  letter-spacing: 2px;
}
.download-desc {
  color: #666;
  font-size: 1rem;
  margin-bottom: 18px;
  text-align: center;
}
.qr-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 18px;
}
.qr-code {
  width: 180px;
  height: 180px;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(80,120,255,0.10);
  margin-bottom: 8px;
}
.qr-tip {
  color: #888;
  font-size: 0.95rem;
}
.download-btn {
  display: inline-block;
  width: 220px;
  background: linear-gradient(90deg, #3b82f6 10%, #06b6d4 90%);
  color: #fff;
  font-size: 1.2rem;
  font-weight: 700;
  text-align: center;
  border: none;
  border-radius: 32px;
  padding: 16px 0;
  margin-top: 18px;
  box-shadow: 0 4px 16px rgba(80,120,255,0.10);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s, transform 0.2s;
}
.download-btn:active {
  background: linear-gradient(90deg, #2563eb 10%, #0891b2 90%);
  transform: scale(0.97);
}
@media (max-width: 600px) {
  .download-card {
    min-width: 0;
    width: 98vw;
    padding: 24px 4vw 24px 4vw;
  }
  .logo {
    width: 64px;
    height: 64px;
  }
  .qr-section {
    display: none;
  }
  .download-btn {
    width: 70vw;
    font-size: 1rem;
    padding: 12px 0;
  }
}
</style> 